﻿using System;
using Newtonsoft.Json;

namespace Labthink.PCSoft.UniversalHost4.Model
{
    /// <summary>
    /// 通信模块的数据类型
    /// </summary>
    public class SocketData
    {
        /// <summary>
        /// 上位机操作码
        /// </summary>
        public string ActionCode { get; set; }

        /// <summary>
        /// 下位机处理结果（0正常）
        /// </summary>
        public int ErrorCode { get; set; }

        /// <summary>
        /// 结果信息
        /// </summary>
        public string ErrorMsg { get; set; }

        /// <summary>
        /// 操作时间
        /// </summary>
        public DateTime ActionTime { get; }

        /// <summary>
        /// 有效数据
        /// </summary>
        public string Value { get; set; }

        /// <summary>
        /// 命令不需要响应
        /// </summary>
        [JsonIgnore]
        public bool HasResponse { get; set; } = true;

        public SocketData(string t) : this()
        {
            Value = t;
            ActionTime = DateTime.Now;
        }

        public SocketData()
        {
            ActionTime = DateTime.Now;
        }
    }
}
